<template>
	<view class="detail">
		<view v-html="dataObj.content"></view>
	</view>
</template>

<script>
	import { requestErrorTip } from '@/common/tools.js';
	
	export default {
		data() {
			return {
				pageObj: {
					serve: {
						id: 6,
						title: '服务协议'
					},
					privacy: {
						id: 9,
						title: '隐私协议'
					},
					about: {
						id: 4,
						title: '关于我们'
					},
					common: {
						id: 8,
						title: '常见问题'
					},
					manual: {
						id: 7,
						title: '使用手册'
					}
				},
				dataObj: {
					id: '',
					content: ''
				}
			}
		},
		onLoad(event) {
			const type = event['type'] || ''; // 获取页面数据类型
			const title = this.pageObj[type]['title'];
			this.dataObj['id'] = this.pageObj[type]['id'];
			uni.setNavigationBarTitle({
			　　title: title
			})
			this.getData();
		},
		// 下拉刷新
		onPullDownRefresh() {
			this.getData();
			setTimeout(function () {
				uni.stopPullDownRefresh();
			}, 1000);
		},
		methods: {
			// 获取数据
			getData() {
				this.$Requset({
					url: this.$Api['user']['set'],
					data: {
						article_id: this.dataObj['id']
					},
					method: 'post',
					success: (res) => {
						const { data, status, msg } = res;
						if (!status) {
							requestErrorTip('toast', msg);
							return;
						}
						this.dataObj['content'] = data['content'];
					},
					fail: (err) => {
						requestErrorTip('toast', '获取数据失败');
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	page{
		background-color: #f5f5f5;
	}
	.detail{
		box-sizing: border-box;
		width: 100%;
		max-width: 100%;
		line-height: 32rpx;
		font-size: 28rpx;
		padding: 30rpx;
		image{
			max-width: 100%;
		}
	}
</style>
